<template>
  <div>
    <el-card class="box-card" style="margin: 20px">
      <div slot="header" class="clearfix">
        <div class="tipText">
          <p>美育素质评分标准</p>
          <p>
            美育素质主要考察学生热爱美和创造美等方面的能力与素质。美育素质测评成绩（C4）=基本分（M1，3分）
          </p>
          <p>基本分、美育素质互评活动成绩，具体计算方法为:</p>
          <p>M1=（基本分（30分）+文艺活动30分+日常行为规范40分 ）*0.03</p>
          <p>
            1.
            基本分：班级集体观看一场红色电影；参加一次院级以上集体或个人文艺活动；进行一次艺术展示，每项10分.
          </p>
          <p>
            2.在各类文艺活动（体育比赛除外）及其他的评奖中获奖（体现较强能力）的，按以下标准奖励：
          </p>
          <table border class="table table-hover">
            <th>获奖</th>
            <th colspan="3">国家级</th>
            <th colspan="3">省级</th>
            <th colspan="3">市级、校级</th>
            <th colspan="3">学院、专业</th>
            <tr>
              <th>等级</th>
              <th>一等</th>
              <th>二等</th>
              <th>三等</th>
              <th>一等</th>
              <th>二等</th>
              <th>三等</th>
              <th>一等</th>
              <th>二等</th>
              <th>三等</th>
              <th>一等</th>
              <th>二等</th>
              <th>三等</th>
            </tr>
            <tr>
              <th>得分</th>
              <td>30</td>
              <td>26</td>
              <td>24</td>
              <td>24</td>
              <td>18</td>
              <td>16</td>
              <td>10</td>
              <td>5</td>
              <td>4</td>
              <td>5</td>
              <td>3</td>
              <td>2</td>
            </tr>
          </table>

          <p>
            思想文化传播备注：凡是集体项目应区分主力与非主力队员，非主力队员得分减半；不能区分主力、非主力队员的项目，2-3人的项目按满分加分，4-6人的项目按满分的1/2加分，7-10人的项目按满分的1/3加分，10人以上的项目按满分的1/4加分；同一项目多次获奖只计高分，不累计加分，主力与非主力由有关职能部门确定。类加分
          </p>
          <p>
            “十佳”项目按同级别的一等奖项目加分；各级优秀奖的加分按照三等奖的一半加分。
          </p>
          <p>
            竞赛主办方为国家级协会的，加分标准参照省级获奖等级加分；主办方为省级协会的，加分标准参照国家级和省级的中间值获奖等级加分；主办方为市级协会的，加分标准仍参照市级获奖等级加分。
          </p>
          <p>
            3.日常行为规范基本得分（40分），遵守《师范学院学生日常行为规范》，未遵守《规范》所规定行为，每项扣5分。
          </p>
        </div>
      </div>
      <div>
        <avue-form
          v-if="update"
          ref="form"
          v-model="obj"
          :option="option"
          @reset-change="emptytChange"
          :rules="rules"
        >
          <template slot="menuForm">
            <el-button
              icon="el-icon-edit"
              type="primary"
              @click="submit"
              v-if="butDis"
              >提 交</el-button
            >
            <el-button
              icon="el-icon-edit"
              @click="updateSub"
              type="primary"
              v-else
              >更新</el-button
            >
          </template>
        </avue-form>
      </div>
    </el-card>
  </div>
</template>
<script>
import { baseUrl } from "@/config/env";
import { httpCheck } from "@/api/studentsPage/approval";
import { willHttp } from "@/api/teacherPage/review";

export default {
  data() {
    return {
      update: true,
      // 控制更新、新增按钮
      butDis: true,
    };
  },
  computed: {
    option() {
      return {
        size: "mini",
        mockBtn: false,
        submitBtn: false,
        printBtn: false,

        column: [
          {
            label: "活动名称",
            prop: "title",
            type: "input",
            span: 10,
            rules: [
              {
                required: true,
                message: "请输入活动名称",
                trigger: "blur",
              },
            ],
          },
          {
            label: "活动类型",
            prop: "type",
            type: "select",
            span: 10,
            dicData: [
              { 
                label: "国家一等",
                 value: 10 
              },
              { 
                label: "国家二等",
                 value: 20 
              },
              { 
                label: "国家三等",
                 value: 30 
              },
              { 
                label: "省级一等",
                 value: 40 
              },
              { 
                label: "省级二等",
                 value: 50 
              },
              { 
                label: "省级三等",
                 value: 60 
              },
              { 
                label: "市，校级一等",
                 value: 70 
              },
              { 
                label: "市，校级二等",
                 value: 80 
              },
              { 
                label: "市，校级三等",
                 value: 90 
              },
              { 
                label: "院级一等",
                 value: 100 
              },
              { 
                label: "院级二等",
                 value: 110 
              },
              { 
                label: "院级三等",
                 value: 120 
              },

            ],
            rules: [
              {
                required: true,
                message: "请输入活动类型",
                trigger: "blur",
              },
            ],
          },
          {
            label: "申报分数",
            prop: "applyFraction",
            type: "number",
            controlsPosition: "",
            span: 10,
            rules: [
              {
                required: true,
                message: "请输入数字",
                trigger: "blur",
                type: "number",
              },
            ],
          },
          {
            label: "活动时间",
            prop: "getTime",
            type: "datetime",
            labelWidth: 90,
            span: 10,
            format: "yyyy-MM-dd hh:mm:ss",
            valueFormat: "timestamp",
            mock: {
              type: "datetime",
              now: true,
            },
            rules: [
              {
                required: true,
                message: "请输入时间",
                trigger: "blur",
              },
            ],
          },

          {
            label: "申报理由",
            span: 18,
            prop: "adit",
            type: "textarea",
            mock: { type: "textarea" },
          },

          {
            label: "附件上传",
            prop: "imgUrl",

            type: "upload",
            propsHttp: {
              home: baseUrl,
              res: "data",
            },
            props: {
              value: "url",
              label: "name",
            },
            span: 24,
            listType: "picture-card",
            tip: "只能上传jpg/png文件，且不超过500kb",
            action: baseUrl + "/basic/sys-file-log/upload",
          },
        ],
      };
    },
  },

  async mounted() {
    let id = this.$route.query.id;
    if (id) {
      await willHttp("cultural", id).then((res) => {
        this.obj.adit = res[0].data.remark;
        this.obj.applyFraction = res[0].data.applyFraction;
        this.obj.getTime = res[0].data.getTime;
        this.obj.title = res[0].data.title;
        this.obj.imgUrl = res[0].data.files;
        this.butDis = false;
      });
    }
  },

  methods: {
    // 更新
    updateSub() {
      this.submitParams("update");
    },
    // 提交done
    submit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.submitParams();
        } else {
          return false;
        }
      });
    },
    async submitParams(par) {
      let params = {};
      params.files = this.obj.imgUrl;
      params.remark = this.obj.adit;
      params.applyFraction = this.obj.applyFraction;
      params.getTime = this.obj.getTime;
      params.title = this.obj.title;
      params.type = this.obj.type;
      if (par) {
        params.id = this.$route.query.id;

        httpCheck("cultural", params, "PUT").then((res) => {
          if (res.code == 1) {
            this.submitFun(par);
          } else {
            this.reload();
            this.$message.error(res.message);
          }
        });
      } else {
        httpCheck("cultural", params, "POST").then((res) => {
          if (res.code == 1) {
            this.submitFun();
          } else {
            this.reload();
            this.$message.error(res.message);
          }
        });
      }
    },
    submitFun(par) {
      if (par) {
        var arr = [" 更新成功", " 将在3s后自动跳转到申报详情页面"];
      } else {
        arr = [" 提交成功", " 将在3s后自动跳转到申报详情页面"];
      }
      let str = arr.join(" <br/> <br/> ");
      this.$message({
        dangerouslyUseHTMLString: true,
        message: str,
        type: "success",
      });
      setTimeout(() => {
        this.$router.push("/studentsPage");
        this.reload();
        this.emptyChange();
      }, 3000);
    },

    reload() {
      this.update = false;
      this.$nextTick(() => {
        this.update = true;
      });
    },
    // 清空方法
    emptyChange() {
      this.obj = {};
    },
  },
};
</script>
<style>
.tipText p {
  text-indent: 2em;
}
.tipText {
  border: 1px solid #455;
  height: 200px;
  overflow: auto;
  padding: 25px;
  padding-top: 0;
  font-size: 13px;
  font-weight: 300;
}
</style>
